package com.zzyl.mapper;


import com.github.pagehelper.Page;
import com.zzyl.entity.CheckIn;
import com.zzyl.entity.Leave;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;


@Mapper
public interface LeaveMapper {

    void createLeave(Leave leave);

    @Select("select * from `leave` where leave_no = #{code}")
    Leave getLeaveByCode(String code);

    @Update("update `leave` set flowStatus = #{flowStatus} where id = #{id} ")
    void updateLeaveByFlowStatus(@Param("id") long id, @Param("flowStatus") Integer flowStatus);

    @Update("update `leave` set status = #{status} where id = #{id}")
    void updateStatus(@Param("id") Long id,@Param("status") Integer status);

    void update(Leave leave);

    Page<List<Leave>> selectByPage(@Param("leaveNo")String leaveNo, @Param("name")String name,
                                     @Param("idCardNo")String idCardNo,
                                     @Param("leaveStart") LocalDateTime leaveStart, @Param("leaveEnd")LocalDateTime leaveEnd,
                                     @Param("applicatId") Long applicatId);

    @Select("select * from `leave` where elder_id = #{elderId} and status = 1")
    Leave selectByElderId(Long elderId);

    @Select("select * from `leave` where leave_no = #{code} and status = 1")
    Leave selectByCode(String code);
}